package main

import "fmt"

func main() {
	var myLen int
	var inputs []int
	var needNum int
	n, _ := fmt.Scan(&myLen)
	if n == 0 {
		fmt.Println(-1, -1)
	} else {
		for i := 0; i < myLen; i++ {
			var input int
			n2, _ := fmt.Scan(&input)
			if n2 != 0 && input > 0 {
				inputs = append(inputs, input)
			}
		}
	}
	n3, _ := fmt.Scan(&needNum)
	if n3 == 0 {
		fmt.Println(-1, -1)
		return
	}

	ints := find(inputs, needNum)
	fmt.Println(ints[0], ints[1])

}

func find(nums []int, target int) []int {
	targetRange := []int{-1, -1}

	leftIndex := getIndex(nums, target, true)

	if leftIndex == len(nums) || nums[leftIndex] != target {
		return targetRange
	}

	targetRange[0] = leftIndex
	targetRange[1] = getIndex(nums, target, false) - 1
	return targetRange
}

func getIndex(nums []int, target int, left bool) int {
	lo := 0
	hi := len(nums)

	for lo < hi {
		mid := (lo + hi) / 2
		if nums[mid] > target || (left && target == nums[mid]) {
			hi = mid
		} else {
			lo = mid + 1
		}
	}
	return lo
}
